package com.briup.day19;

import com.sun.org.apache.bcel.internal.generic.NEW;

public class Test_Daemon {
    public static void main(String[] args) {
        //1.创建线程的第一种方法
        Thread t1=new Thread(){
            public void run(){
                String name = Thread.currentThread().getName();
                System.out.println(name);
                for(int i=0;i<=30;i++){
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println("线程1"+name+"i: "+i);
                }
            }
        };
        t1.setName("男神");
        t1.start();
        Thread t2=new Thread(new Runnable() {
            @Override
            public void run() {
                String name1 = Thread.currentThread().getName();
                for(int i=100;i>=50;i--){
                    try {
                        Thread.sleep(200);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println("线程1"+name1+"i: "+i);

                }
            }
        });
        t2.setName("备胎");
        t2.setDaemon(true);
        t2.start();
    }
}
